const expressJWT = require('express-jwt');

// 引入常量密钥
const { TOKEN_KEY } = require('./const');

const jwtAuth = expressJWT({
    secret: TOKEN_KEY,//生产token配置时的密钥
    algorithms: ['HS256'],//设置jwt的算法位HS256
    credentialsRequired: false//对于没有token的请求不进行解析
}).unless({
    //用于设置不需要验证token的路径
    path: ['/admins/superLogin', '/lessors/loginLessors', '/lessors/registerLessors', '/lessors/isLessors','/logs/createLogs']
});

module.exports = jwtAuth;